package com.cxz.demo;

import annotation.SoiScan;
import cn.hutool.json.JSONArray;
import cn.hutool.json.JSONObject;
import com.cxz.demo.model.UserInfo;
import context.SoiContext;
import core.DefaultSOIContainer;
import model.SoiNode;

/**
 * @className: DemoOne
 * @author: ocxz1
 * @date: 2025/3/26 下午5:23
 * @Version: 1.0
 * @description: soi
 */
public class DemoOne {

    public static void main(String[] args) {

        DefaultSOIContainer defaultSOIContainer = new DefaultSOIContainer();

        SoiNode soiNode = new SoiNode();
        soiNode.setCheckRuleScript("return userInfo.getName() == \"张三\"");

        JSONArray objects = new JSONArray();
        JSONObject jo = new JSONObject();
        jo.set("name", "userInfo");
        jo.set("type", UserInfo.class.getName());
        objects.add(jo);

        soiNode.setParamsJson(objects);
        SoiContext soiContext = new SoiContext();
        UserInfo userInfo = new UserInfo();
        userInfo.setName("张三");
        soiContext.putBusinessData(userInfo);

        boolean b = defaultSOIContainer.evaluateCheckRule(soiNode, soiContext);
        System.out.println(b);
    }
}
